package com.qs;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class TestApp {

	public static void main(String[] args) {
		test();
		//test2();
		//test3();
		//testCycle();
	}

	private static void test() {
		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
//		IndexService indexService = context.getBean(IndexService.class);
		IndexServiceImpl indexService = context.getBean(IndexServiceImpl.class);
		System.out.println("===>>indexService=" + indexService);
	}

	private static void test2() {
		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
		context.register(AppConfig.class);
		context.refresh();
		IndexService indexService = context.getBean(IndexService.class);
		System.out.println("===>>indexService=" + indexService);
	}

	public static void test3(){
		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
		context.addBeanFactoryPostProcessor(new MyBeanDefinitionRegistryPostProcessor());
		context.refresh();
	}

	public static void testCycle(){
		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
		X beanX = context.getBean(X.class);
		Y beanY = context.getBean(Y.class);
	}
}
